package pap.test.fcPuCc;

import gov.nasa.jpf.jvm.Verify;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;

public abstract class Task {

	ExecutorService executors;
	static AtomicInteger fcRunning = new AtomicInteger(0);
	static AtomicInteger puRunning = new AtomicInteger(0);
	static AtomicInteger ccRunning = new AtomicInteger(0);

	public Task(int threadNum) {
		Verify.beginAtomic();
		executors = Executors.newFixedThreadPool(threadNum);
		Verify.endAtomic();
	}

	protected abstract void mainTask() throws InterruptedException;

	public void start() {

		executors.execute(new Runnable() {

			@Override
			public void run() {
				try {
					mainTask();
					executors.shutdown();
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		});
	}

}